
kmpkg_from_git(
	OUT_SOURCE_PATH SOURCE_PATH
	URL "https://gitee.com/kumo-hub/brotli.git"
	REF ed738e842d2fbdf2d6459e39267a633c4a9b2f5d
	PATCHES
		install.patch
		fix-arm-uwp.patch
		pkgconfig.patch
		emscripten.patch
)

kmpkg_cmake_configure(
    SOURCE_PATH "${SOURCE_PATH}"
    OPTIONS
        -DBROTLI_DISABLE_TESTS=ON
)
kmpkg_cmake_install()
kmpkg_copy_pdbs()
kmpkg_fixup_pkgconfig()
kmpkg_cmake_config_fixup(CONFIG_PATH share/unofficial-brotli PACKAGE_NAME unofficial-brotli)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/tools")

# Under emscripten the brotli executable tool is produced with .js extension but kmpkg_copy_tools
# has no special behaviour in this case and searches for the tool name with no extension
if(KMPKG_TARGET_IS_EMSCRIPTEN)
	set(TOOL_SUFFIX ".js" )
endif()

kmpkg_copy_tools(TOOL_NAMES "brotli${TOOL_SUFFIX}" SEARCH_DIR "${CURRENT_PACKAGES_DIR}/tools/brotli")

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
kmpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
